{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}

{% block title %}Mapping
{% endblock %}

{% block content %}
<form action="/web_mapping_post_search" method="post" id="postattr" name="postattr">
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />

    <div class="form col-md-2">
        <select id="search_type" name="search_type" class="form-control">
            <option value="1">表名</option>
            <option value="2">表描述</option>
            <option value="3">列名</option>
            <option value="4">表描述</option>
        </select>
    </div>

    <div class="form col-md-8">
        <input class="form-control" type="text" name="search_text">
    </div>

    <div class="form col-md-1">
        <input type="submit" value="搜索" class="btn" ></input>
    </div>
</form>

<br><br>
<table class="table table-bordered">
    {% if table_flag %}
        <tr>
            <th>数据库</th>
            <th>表名</th>
            <th>表描述</th>
        </tr>
        {% if json_data%}
            {% for i in json_data %}
                <tr>

                    <td>{{ i.get('db_name') }}</td>
                    <td><a href="/web_mapping_post_search?table_id={{ i.get('table_id') }}"> {{ i.get('table_name') }}</a></td>
                    <td>{{ i.get('table_describe') }}</td>
                </tr>
            {% endfor %}
        {% endif %}

    {% else %}
        <tr>
            <th>数据库</th>
            <th>表名</th>
            <th>表描述</th>
            <th>列名</th>
            <th>列描述</th>

            <th>来源库</th>
            <th>来源表</th>
            <th>来源列</th>
            <th>所有者</th>
        </tr>
        {% if json_data%}
            {% for i in json_data %}
                <tr>

                    <td>{{ i.get('db_name') }}</td>
                    <td>{{ i.get('table_name') }}</td>
                    <td>{{ i.get('table_describe') }}</td>
                    <td>{{ i.get('column_name') }}</td>
                    <td>{{ i.get('column_describe') }}</td>
                    <td>{{ i.get('source_db') }}</td>
                    <td>{{ i.get('source_table') }}</td>
                    <td>{{ i.get('source_column') }}</td>
                    <td>{{ i.get('owner_name') }}</td>

                </tr>
            {% endfor %}
        {% endif %}

    {% endif %}

</table>
{% endblock %}

